// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   homePage_delete_ok.java

package ecommerce.config.website;

import include.nseer_db.nseer_db_backup1;
import java.io.File;
import java.io.IOException;
import java.sql.ResultSet;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import javax.servlet.jsp.JspFactory;

public class homePage_delete_ok extends HttpServlet
{

	public homePage_delete_ok()
	{
	}

	public synchronized void service(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException
	{
		HttpSession dbSession = request.getSession();
		JspFactory _jspxFactory = JspFactory.getDefaultFactory();
		javax.servlet.jsp.PageContext pageContext = _jspxFactory.getPageContext(this, request, response, "", true, 8192, true);
		ServletContext dbApplication = dbSession.getServletContext();
		HttpSession session = request.getSession();
		try
		{
			ServletContext context = session.getServletContext();
			String path = context.getRealPath("/");
			nseer_db_backup1 ecommerce_db = new nseer_db_backup1(dbApplication);
			if (ecommerce_db.conn((String)dbSession.getAttribute("unit_db_name")))
			{
				String del[] = (String[])session.getAttribute("del");
				for (int p = 0; p < del.length; p++)
				{
					String sql3 = (new StringBuilder("select * from ecommerce_web_template where id='")).append(del[p]).append("'").toString();
					ResultSet rs = ecommerce_db.executeQuery(sql3);
					if (rs.next())
					{
						File file = new File((new StringBuilder(String.valueOf(path))).append("ecommerce/homePage_template/").append(rs.getString("attachment1")).toString());
						file.delete();
						String sql = (new StringBuilder("delete from ecommerce_web_template where id='")).append(del[p]).append("'").toString();
						ecommerce_db.executeUpdate(sql);
					}
				}

				ecommerce_db.commit();
				ecommerce_db.close();
				response.sendRedirect("ecommerce/config/website/homePage.jsp");
			} else
			{
				response.sendRedirect("error_conn.htm");
			}
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
	}
}
